package com.happy.services;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.happy.entity.User;
import com.happy.entity.UserInfo;
import com.happy.exception.ServicesException;
import com.core.orm.hibernate.*;

@Service
@Transactional
public class UserServices {
	private HibernateDao<User, Integer> userDao;


	@Autowired
	public void setSessionFactory(SessionFactory sessionFactory) {
		userDao = new HibernateDao<User, Integer>(sessionFactory, User.class);
	}
    public void saveUserInfo(UserInfo info)
    {
    	
    }
	/**
	 * @param id
	 * @return
	 */
	public User get(Integer id)throws ServicesException {
		return userDao.get(id);
	}

	public User getUserByName(String name)throws ServicesException {
		return userDao.findUniqueBy("userName", name);

	}
	public List<User> getAll()throws ServicesException {
		
		return userDao.getAll();
	}

}
